<template>
  <div class="">
    <div class="">
      <el-date-picker v-model="dateVal" type="daterange" placeholder="请选择日期" />
    </div>
    <upload :kind="1" :file="imgRef" @setUrl="setUrl" />
    <loader :loadShow="loadShow" />
  </div>
</template>

<script setup>
import { ref, onBeforeMount } from 'vue'
import { sessionApi } from '@/commons/api'
import routes from '@/commons/router'
import Loader from '@/components/loader/Loader'
import Upload from '@/components/upload/Upload'

// 挂载前判断用户是否登录，如果已登录，则直接跳转到主页
onBeforeMount(() => {
  // hasLogin()
})

// 定义是否显示加载中的变量
let loadShow = ref(false)

// hasLogin 判断用户是否已经登录，如果已登录，则直接跳转到主页
const hasLogin = () => {
  routes.replace('/main')
}

const dateVal = ref('')

// setUrl 回调获取上传文件的地址
const imgRef = ref({id: '', name: '', url: '', thumb: ''})
const imgListRef = ref([])
const fileRef = ref({id: '', name: '', url: ''})
const fileListRef = ref([])
const setUrl = (kind, file) => {
  switch (kind) {
    case 1:
      imgRef.value = file
      break;
    case 2:
      imgListRef.value = file
      break;
    case 3:
      fileRef.value = file
      break;
    case 4:
      fileListRef.value = file
      break;
  }
}
</script>

<style scoped>
</style>